﻿@model Orchard.Projections.Settings.ProjectionPartSettings
@using Orchard.Projections.Models;
@using Orchard.Projections.ViewModels;

<fieldset>
    @Html.LabelFor(m => m.QueryLayoutRecordId, T("Default Query"))
    <select id="@Html.FieldIdFor(m => m.QueryLayoutRecordId)" name="@Html.FieldNameFor(m => m.QueryLayoutRecordId)">
        @{
            // no default query
            var defaultQueryRecord = Model.QueryRecordEntries.Where(q => q.Id == -1).FirstOrDefault();
            @Html.SelectOption(Model.QueryLayoutRecordId, defaultQueryRecord.Id.ToString(), T("No default query").Text)
        }
        @foreach (QueryRecordEntry queryRecord in Model.QueryRecordEntries.Where(q => q.Id != -1).OrderBy(x => x.Name)) {
            <optgroup label="@queryRecord.Name">
                @Html.SelectOption(Model.QueryLayoutRecordId, queryRecord.Id + ";-1", queryRecord.Name + " " + T("(Default Layout)").Text)

                @foreach (LayoutRecordEntry layoutRecord in queryRecord.LayoutRecordEntries.OrderBy(x => x.Description)) {
                    @Html.SelectOption(Model.QueryLayoutRecordId, queryRecord.Id + ";" + layoutRecord.Id, queryRecord.Name + " " + T("({0})", layoutRecord.Description).Text)
                }
            </optgroup>
        }
    </select>
    <span class="hint">@T("The query to display.")</span>
</fieldset>
<fieldset>
    <span class="hint">@T("Select lock editing to prevent the user from editing the default choice")</span>

    <div>
        <div class="row-settings-projection-part">
            <div class="col-settings-projection-part">
                @Html.LabelFor(m => m.Items, T("Items to display"))
                @Html.TextBoxFor(m => m.Items, new { @class = "text small" })
            </div>
            <div class="col-settings-projection-part lock-editing-projection-part-field">
                @Html.CheckBoxFor(m => m.LockEditingItems)
                <label class="forcheckbox" for="@Html.FieldIdFor(m => m.LockEditingItems)">@T("Lock Editing")</label>
            </div>
        </div>
        <span class="hint">@T("The number of items to display. Enter 0 for no limit. When using pagination, this is the number of items per page.")</span>
    </div>

    <div>
        <div class="row-settings-projection-part">
            <div class="col-settings-projection-part">
                @Html.LabelFor(m => m.Skip, T("Offset"))
                @Html.TextBoxFor(m => m.Skip, new { @class = "text small" })
            </div>
            <div class="col-settings-projection-part lock-editing-projection-part-field">
                @Html.CheckBoxFor(m => m.LockEditingSkip)
                <label class="forcheckbox" for="@Html.FieldIdFor(m => m.LockEditingSkip)">@T("Lock Editing")</label>
            </div>
        </div>
        <span class="hint">@T("The number of items to skip (e.g., if 2 is entered, the first 2 items won't be diplayed).")</span>
    </div>

    <div>
        <div class="row-settings-projection-part">
            <div class="col-settings-projection-part">
                @Html.LabelFor(m => m.MaxItems, T("Maximum items"))
                @Html.TextBoxFor(m => m.MaxItems, new { @class = "text small" })
            </div>
            <div class="col-settings-projection-part lock-editing-projection-part-field">
                @Html.CheckBoxFor(m => m.LockEditingMaxItems)
                <label class="forcheckbox" for="@Html.FieldIdFor(m => m.LockEditingMaxItems)">@T("Lock Editing")</label>
            </div>
        </div>
        <span class="hint">@T("Maximum number of items which can be queried at once. Use 0 for unlimited. This is only used as a failsafe when the number of items comes from a user-provided source such as the query string.")</span>
    </div>

    <div>
        <div class="row-settings-projection-part">
            <div class="col-settings-projection-part">
                @Html.LabelFor(m => m.PagerSuffix, T("Suffix"))
                @Html.TextBoxFor(m => m.PagerSuffix, new { @class = "text" })
            </div>
            <div class="col-settings-projection-part lock-editing-projection-part-field">
                @Html.CheckBoxFor(m => m.LockEditingPagerSuffix)
                <label class="forcheckbox" for="@Html.FieldIdFor(m => m.LockEditingPagerSuffix)">@T("Lock Editing")</label>
            </div>
        </div>
        <span class="hint">@T("Optional. Provide a suffix to use when multiple pagers are displayed on the same page, e.g., when using multiple Projection Widgets, or to define alternates.")</span>
    </div>

    <div>
        <div class="row-settings-projection-part">
            <div class="col-settings-projection-part">
                @Html.CheckBoxFor(m => m.DisplayPager)
                <label class="forcheckbox" for="@Html.FieldIdFor(m => m.DisplayPager)">@T("Show pager")</label>
            </div>
            <div class="col-settings-projection-part">
                @Html.CheckBoxFor(m => m.LockEditingDisplayPager)
                <label class="forcheckbox" for="@Html.FieldIdFor(m => m.LockEditingDisplayPager)">@T("Lock Editing")</label>
            </div>
        </div>
        <span class="hint">@T("Check to add a pager to the list.")</span>
    </div>
</fieldset>
<fieldset>
    @Html.LabelFor(m => m.FilterQueryRecordId, T("Filter Queries"))
    <select id="@Html.FieldIdFor(m => m.FilterQueryRecordsId)" multiple="multiple" size="10" name="@Html.FieldNameFor(m => m.FilterQueryRecordsId)">
        @foreach (QueryRecordEntry queryRecord in Model.QueryRecordEntries.Where(q => q.Id != -1).OrderBy(x => x.Name)) {
            <optgroup label="@queryRecord.Name">
                @Html.SelectOption(queryRecord.Id + ";-1", Model.FilterQueryRecordsId.Contains(queryRecord.Id + ";-1"), queryRecord.Name + " " + T("(Default Layout)").Text)

                @foreach (LayoutRecordEntry layoutRecord in queryRecord.LayoutRecordEntries.OrderBy(x => x.Description)) {
                    @Html.SelectOption(queryRecord.Id + ";" + layoutRecord.Id, Model.FilterQueryRecordsId.Contains(queryRecord.Id + ";" + layoutRecord.Id), queryRecord.Name + " " + T("({0})", layoutRecord.Description).Text)               
                }
            </optgroup>
        }
    </select>
    <span class="hint">@T("Select which queries to display to the user. If there are no selections, all queries will be used.")</span>
</fieldset>